package com.douxg.learning.springboot.resttemplate;

import com.douxg.learning.springboot.resttemplate.service.impl.MainServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @Description
 * @Author douxg
 * @Date 2020/3/16 11:45
 */
@RestController
@RequestMapping("")
public class TestController {
    public TestController() {
        System.out.println("testcontroller");
    }

    @Resource
    private RestTemplate restTemplate;

    @Autowired
    private MainServiceImpl mainServiceImpl;

    @RequestMapping("/")
    public String index() {
        ResponseEntity<String> forEntity = restTemplate.getForEntity("http://127.0.0.1:8080/", String.class);
        return forEntity.getBody();
    }

    @RequestMapping("/other")
    public String other() {
        return "这是other";
    }

//    @RequestMapping("/mainSub")
//    public String mainSub() {
//        JdbcTemplate jdbcTemplate = new JdbcTemplate();
//        DruidDataSource druidDataSource = new DruidDataSource();
//        jdbcTemplate.setDataSource(druidDataSource);
//        TransactionTemplate transactionTemplate = new TransactionTemplate();
//        transactionTemplate.execute(transactionStatus -> {
//            return jdbcTemplate.queryForMap("");
//        });
//        return mainServiceImpl.in();
//
//    }
}
